<?php

require_once '../application/models/DB.php';
include_once APPLICATION_PATH . '/models/Super_Model.php';

class Super_Model_Admin extends Super_Model {

    public function removeRow($table_name, $id_row) {
        if (!empty($table_name) && !empty($id_row)) {
            $sql = 'DELETE FROM `' . addslashes($table_name) . '` WHERE `id` = ' . (int) $id_row;
            return $this->Exec($sql);
        } else {
            $this->error(__METHOD__ . ' empty parameters');
        }
    }

    public function createUrl($str, $table = 'pages'){
        if(!empty ($str)){
            $url = strtolower (_translit (trim($str)));
            $sql = 'SELECT `url` FROM `pages` WHERE `url` = \''.$url.'\'';
            $empty_url = $this->getOne($sql);
            if(!empty ($empty_url))
                return $url.'_'.md5(time());
            else
                return $url;
        }
        return 'url_'.md5(time());
    }

}